package com.wthink.hzgj.busInfo.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wthink.hzgj.BusApplication
import com.wthink.hzgj.busInfo.BusInfo
import com.wthink.hzgj.data.Result
import com.wthink.hzgj.data.domain.BusConfig
import com.wthink.hzgj.service.DevService
import com.wthink.hzgj.util.toast
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

class BusConfigViewmodel : ViewModel(){

    val colorsItems = arrayListOf( "蓝色", "黄色", "黑色", "白色", "绿色", "黄绿色", "其他", "未知")
    val busConfigInfo = MutableLiveData<BusInfo>()

    val vdr_model = MutableLiveData("")
    val vdr_vendorid = MutableLiveData("")
    val vid = MutableLiveData("")
    val simno = MutableLiveData("")
    val car_num = MutableLiveData("")
    val province_id = MutableLiveData("")
    val city_id = MutableLiveData("")
    val car_vin = MutableLiveData("")


    fun config(busConfig: BusInfo){
/*
        viewModelScope.launch(Dispatchers.IO) {
            val netconfigSer = DevService.setBusconfig(busConfig)
            if (netconfigSer is Result.Success) {
                withContext(Dispatchers.Main) {
                    toast(BusApplication.busContext, "配置成功")
                }
            } else if (netconfigSer is Result.Error) {
                withContext(Dispatchers.Main) {
                    toast(BusApplication.busContext, netconfigSer.exception.toString())
                }
            }
        }
*/
    }
}